
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@page import="com.tss.util.*"%>
<%@page import="com.jedi.*"%>
<%@page import="com.store.*"%>
<%@page import="com.store.ApproveExp"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@include file="../global_var.jsp"%>
<%@include file="../check_login.jsp"%>
<%
User just_user = (User)session.getAttribute("LoginUser");
String power_enable_id = "10404";

if (!just_user.hasPower(power_enable_id)) {
	out.println(strNoPowerInfo); 
	return;
}
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
UserMgr userMgr = new UserMgr();
User user = (User)session.getAttribute("LoginUser");
List list = null;
String cmd = ParamUtils.getParameter(request,"cmd","");
String strErr = "";
String author_id   = "";
String author_name = "";
if (user != null && !user.getId().trim().equals("")) {
	author_id = user.getId();
	author_name = user.getUserName();
}

String user_id      = ParamUtils.getParameter(request,"user_id","");
String user_name    = ParamUtils.getParameter(request,"user_name","");
String approve_val  = ParamUtils.getParameter(request,"approve_val","0");
String project_id   = ParamUtils.getParameter(request,"project_id","");
String appeal[]     = ParamUtils.getParameters(request,"appeal");
String exp_desc     = ParamUtils.getParameter(request,"exp_desc","");
String exp_time     = ParamUtils.getParameter(request,"exp_time","");
String custemer = ParamUtils.getParameter(request,"custemer","");
//String appeal_cust  = ParamUtils.getParameter(request,"appeal_cust","");
//String appeal_sales = ParamUtils.getParameter(request,"appeal_sales","");


if (cmd.trim().equals("insert")) {
	if (strErr.trim().equals("") && user_id.trim().equals("")) {
		strErr = "请选择工程师!";
	}
	if (strErr.trim().equals("") && !user_id.trim().equals("")) {
		User tObj = userMgr.get(user_id,false);
		if (tObj == null || tObj.getId().trim().equals("")) 
			strErr = "工程师信息不存在!";
		else
			user_name = tObj.getUserName();
	}
	if (strErr.trim().equals("")) {
		try {
			Integer.parseInt(approve_val);
		}
		catch(Exception ex) {
			strErr = "客户打分必须为整数!";
		}
	}
	
	/*if (strErr.trim().equals("") && project_id.trim().equals("")) {
		strErr = "请选择工单号!";
	}*/
	
	if (strErr.trim().equals("") && exp_desc.length() >= 100) {
		strErr = "描述不能超过100字符!";
	}

	if (strErr.trim().equals("")) {
		ApproveExp approveExp = new ApproveExp();
		if (ParamUtils.inArray("appeal_cust",appeal)) approveExp.setAppealCust(1);
		if (ParamUtils.inArray("appeal_sales",appeal)) approveExp.setAppealSales(1);
		approveExp.setUserId(user_id);
		approveExp.setUserName(user_name);
		approveExp.setApproveVal(Integer.parseInt(approve_val));
		approveExp.setAuthorId(author_id);
		approveExp.setAuthorName(author_name);
		approveExp.setProjectId(project_id);
		approveExp.setExpDesc(exp_desc);
		approveExp.insert();
		if (approveExp.hasErr()) strErr = approveExp.getErrHtml();
	}
}
%>
<html>
<head>
    <base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
   <link href="style/main.css" rel="stylesheet" type="text/css">
<script language="javascript" src="js/common.js"></script>
<script language="javascript">
function chk_submit() {
	var oForm = document.operatorForm;
	if (oForm.user_id.selectedIndex <0) {
		alert("请选择工程师!");
		oForm.user_id.focus();
		return false;
	}
	oForm.cmd.value = "insert";
	return true;
}

function clk_select_task() {
	var str = "approve_mgt/storage_sel_task.jsp";
	var oForm = document.operatorForm;
	var r = window.showModalDialog('../selectFrm.htm',str,'dialogHeight: 400px;dialogWidth: 700px;center:yes;dialogHide:no;status:no;help: no');
   	if(r != null)
   	{
   	var valArray = r.split(",");
   		oForm.project_id.value = valArray[0];
   		oForm.user_id.value = valArray[1];
   		oForm.user_name.value = valArray[2];
   		oForm.custemer.value = valArray[3];
   	}
}
</script>
</head>
<body 	leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td >
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="31" valign="top" background="images/title_bk_01.gif"
					style="padding-left:10px;padding-top:6px;">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="50%" style="color:#FFFFFF;font-size:13px;"><b>客户满意度</b>
						-&gt; <b>添加满意度</b></td>
						<td width="50%" align="right" style="padding-right:10px;">&nbsp; <span
							onclick="right_menu_clk('approve_detail_list.jsp');"
							style="cursor:hand;color:#FFFFFF;font-size:12px;text-de--ation: underline;">满意度列表</span>
						</td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<td height="100" align="center" valign="top"
					style="padding-top:20px;padding-bottom:10px;">
					<form name="operatorForm" method="post"
						onsubmit="return chk_submit();">
				<table width="80%" border="0" cellpadding="3" cellspacing="1"
					bgcolor="#FFFFFF">
					<%if (!strErr.trim().equals("")) {%>
					<tr>
						<td width="30%" height="28" align="right" bgcolor="#858585"><font
							color="#FFFFFF">错误提示：</font></td>
						<td bgcolor="#EDEDF0"><font color=red><%=strErr%></font>&nbsp;</td>
					</tr>
					<%}%>
					
					
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">客户名称：</font></td>
						<td bgcolor="#EDEDF0">
						<input name="project_id" type="hidden" class="inputbox" value="<%=project_id%>" size="30" maxlength="50" class="inputBox"  style="background-color:#EDEDE8" readonly="readonly">
						<input name="custemer" type="text" class="inputbox" value="<%=custemer%>" size="30" maxlength="50" class="inputBox"  style="background-color:#EDEDE8" readonly="readonly">
						<input type="button" value="选择工单" onclick="clk_select_task();"
							class="inputButton"></td>
					</tr>
					<tr>
						<td width="30%" height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">工程师：</font></td>
						<td bgcolor="#D7D7DB">
							<input name="user_id" type="hidden" class="inputbox" value="<%=user_id%>" size="30" maxlength="30">
							<input name="user_name" type="text" class="inputbox" value="<%=user_name%>" size="30" maxlength="50" class="inputBox"  style="background-color:#EDEDE8" readonly="readonly" >
            	      		</td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">投拆：</font></td>
						<td bgcolor="#EDEDF0"><input type="checkbox" name="appeal"
							value="appeal_cust"
							<%if (ParamUtils.inArray("appeal_cust",appeal)){%> checked <%}%>>
						客户投拆 &nbsp;&nbsp; <input type="checkbox" name="appeal"
							value="appeal_sales"
							<%if (ParamUtils.inArray("appeal_sales",appeal)){%> checked <%}%>>
						销售人员投拆 &nbsp;&nbsp;</td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">描述：</font></td>
						<td bgcolor="#EDEDF0"><textarea name="exp_desc" cols="40" rows="5"><%=exp_desc%></textarea>
						</td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">客户打分：</font></td>
						<td bgcolor="#EDEDF0"><input name="approve_val" type="text"
							class="inputbox" value="<%=approve_val%>" size="3" maxlength="3">
						</td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#EDEDF0">&nbsp;</td>
						<td bgcolor="#EDEDF0"><input type="submit" name="submit"
							value="提 交" class="inputButton"> <input type="reset" name="reset"
							value="重 写" class="inputButton"> <input type="hidden" name="cmd"
							value=""></td>
					</tr>
				
				</table>
					</form>
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
<%if (cmd.equals("insert") && strErr.trim().equals("")){%>
<script language="javascript">
alert("满意度信息添加成功!");
location.href="approve_list.jsp";
</script>
<%}%>
</body>
</html>
